Database management system is to organize and retrieve data in a faster way.
The 3 Normalization rules:
There must not be repeating data anywhere in one table.---First Normal Form
The attributes in the table are dependent on the entire primary key. ---Second Normal Form
The primary key in the table is the only depending resource of other attributes in the table. ---Third Normal Form
Definition:
Primary Key: uniquely identifies each record in the table
Foreign Key: a field in a relational table that matches the primary key in another table ( usually the previous table). Example For theFirst Normal Form ( 1NF) :
The following database table is WRONG.
- The "Supplier Name" column has duplicate data.
The following database table is the CORRECTED one.
Example For the Second Normal Form (2NF):
Note: The table should be already in the First Normal Form
WRONG
- Songs and Artist are the composite primary key
- Artist is not related to Time and Genre, so we have to split it into 2 or more tables
CORRECTED
- For this time, I split it into 2 tables. - The FIRST table is called the songs table - The SECOND table is called the Artist table
Example For the Third Normal Form (3NF)
Note: The table should be already in the First and Second Normal Form.
WRONG
- this table meets the requirements of 2NF but fail the requirements to 3NF
- Supplier Tel# is dependent on Name which is not our Primary key.
CORRECTED
WRONG
EDITED
ER Diagram
- it is a particular graphic that illustrates the interrelationship between entities
Two Rules
1.You CANNOT contain a null value if it is a PK
2.You CAN contain a null value if it is a non-primary key
- there are three relationships: 1. one to one 2. one to many 3. many to many
For the One-to-one relationship
- one school has one phone number, that particular phone number should only belong to one school
For the One-to-many relationship
- there is one folder collecting data, and there are many pieces of information being collected
- one school has many students
For the Many-to many relationship
- many-to-many usually cannot connect to each other, so we have to add a new table between them
Examples
- there are many suppliers of laptops,and the laptops are being sold in many shops
- one block can have many courses, one course can have many blocks
Summery of Database Knowledge
Database management system is to organize and retrieve data in a faster way.
The 3 Normalization rules:
Definition:
Primary Key: uniquely identifies each record in the tableForeign Key: a field in a relational table that matches the primary key in another table ( usually the previous table).
Example For the First Normal Form ( 1NF) :
The following database table is WRONG.
- The "Supplier Name" column has duplicate data.
The following database table is the CORRECTED one.
Example For the Second Normal Form (2NF):
Note: The table should be already in the First Normal Form
WRONG
- Songs and Artist are the composite primary key
- Artist is not related to Time and Genre, so we have to split it into 2 or more tables
CORRECTED
- For this time, I split it into 2 tables.- The FIRST table is called the songs table
- The SECOND table is called the Artist table
Example For the Third Normal Form (3NF)
Note: The table should be already in the First and Second Normal Form.
WRONG
- this table meets the requirements of 2NF but fail the requirements to 3NF- Supplier Tel# is dependent on Name which is not our Primary key.
CORRECTED
WRONG
EDITED
ER Diagram
- it is a particular graphic that illustrates the interrelationship between entities
Two Rules1.You CANNOT contain a null value if it is a PK
2.You CAN contain a null value if it is a non-primary key
- there are three relationships: 1. one to one 2. one to many 3. many to many
For the One-to-one relationship
- one school has one phone number, that particular phone number should only belong to one school
For the One-to-many relationship
- there is one folder collecting data, and there are many pieces of information being collected
- one school has many students
For the Many-to many relationship
- many-to-many usually cannot connect to each other, so we have to add a new table between them
Examples
- there are many suppliers of laptops,and the laptops are being sold in many shops
- one block can have many courses, one course can have many blocks
Souce